use "cnty_analysis.dta"

** create state variable for FEs
encode state, gen(st)

** Table 1
sum boxes pct_food_insecure foodfinder_pantries pct_urban pop_dens pct_white pct_black pct_hispanic pct_college per_cap_inc pct_trump

** Table 2
glm boxes_pc pct_food_insecure foodfinder_pantries_pc_ln i.st, family(gamma) link(log) robust
glm boxes_pc pct_food_insecure foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st, family(gamma) link(log) robust
glm boxes_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln i.st, family(gamma) link(log) robust
glm boxes_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st, family(gamma) link(log) robust

** Figure 5 (plot created in Figure5.R)
glm boxes_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln pct_urban pop_dens_ln pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st, family(gamma) link(log) robust
margins, at(pct_food_insecure = (8.5 17.9) foodfinder_pantries_pc_ln = (0 2.833213 4.025352)) atmeans post

** Table A1
logit no_food pct_food_insecure foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st

** Table A2
glm money_pc pct_food_insecure foodfinder_pantries_pc_ln i.st, family(gamma) link(log) robust
glm money_pc pct_food_insecure foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st, family(gamma) link(log) robust
glm money_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln i.st, family(gamma) link(log) robust
glm money_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st, family(gamma) link(log) robust

** Table A3
reg boxes_pc_ln pct_food_insecure foodfinder_pantries_pc_ln i.st
reg boxes_pc_ln pct_food_insecure foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st
reg boxes_pc_ln c.pct_food_insecure##c.foodfinder_pantries_pc_ln i.st
reg boxes_pc_ln c.pct_food_insecure##c.foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st

** Table A5
glm boxes_non_bank_pc pct_food_insecure foodfinder_pantries_pc_ln i.st, family(gamma) link(log) robust
glm boxes_non_bank_pc pct_food_insecure foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st, family(gamma) link(log) robust

glm boxes_non_bank_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln i.st, family(gamma) link(log) robust
glm boxes_non_bank_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st, family(gamma) link(log) robust

** Table 3
** define counties as above vs. below mean on security and pantries
gen high_pantries = 1 if foodfinder_pantries_pc_ln >= 2.842325 // this is the log of the median value of pantries
replace high_pantries = 0 if high_pantries == .
replace high_pantries = . if pct_food_insecure < 12.9 // exclude low insecurity counties from this analysis

** Column 1
logit high_pantries pct_urban pop_dens_ln pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st
** Column 2
glm foodfinder_pantries_pc pct_urban pop_dens_ln pct_food_insecure pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st, family(gamma) link(log) robust

clear

** Table A4
use "cnty_admin_analysis.dta"

encode state, gen(st)

** Columns 1-4
glm boxes_pc pct_food_insecure foodfinder_pantries_pc_ln i.st if biden == 0, family(gamma) link(log) robust
glm boxes_pc pct_food_insecure foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st if biden == 0, family(gamma) link(log) robust
glm boxes_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln i.st if biden == 0, family(gamma) link(log) robust
glm boxes_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st if biden == 0, family(gamma) link(log) robust

** Column 5-8
glm boxes_pc pct_food_insecure foodfinder_pantries_pc_ln i.st if biden == 1, family(gamma) link(log) robust
glm boxes_pc pct_food_insecure foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st if biden == 1, family(gamma) link(log) robust
glm boxes_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln i.st if biden == 1, family(gamma) link(log) robust
glm boxes_pc c.pct_food_insecure##c.foodfinder_pantries_pc_ln pct_urban pop_dens_ln  pct_white pct_black pct_hispanic pct_college per_cap_inc_ln pct_trump i.st if biden == 1, family(gamma) link(log) robust

